package com.bdqn.service.impl;

import com.bdqn.mapper.BookMapper;
import com.bdqn.pojo.Book;
import com.bdqn.service.BookService;

import java.util.List;

/**
 * BookServiceImpl
 *
 * @author LILIBO
 * @since 2024/7/23
 */
public class BookServiceImpl implements BookService {

    // 使用Spring注入数据访问层Bean
    private BookMapper bookMapper;

    public void setBookMapper(BookMapper bookMapper) {
        this.bookMapper = bookMapper;
    }

    /**
     * 添加图书
     *
     * @param book
     * @return
     */
    @Override
    public int add(Book book) {
        return bookMapper.add(book);
    }

    /**
     * 修改图书信息
     *
     * @param book
     * @return
     */
    @Override
    public int upd(Book book) {
        return bookMapper.upd(book);
    }

    /**
     * 根据ID删除图书
     *
     * @param id
     * @return
     */
    @Override
    public int del(Integer id) {
        return bookMapper.del(id);
    }

    /**
     * 查询所有图书
     *
     * @return
     */
    @Override
    public List<Book> list() {
        return bookMapper.list();
    }

}
